/**
 * Created by no1 on 2015/7/10.
 */


'use strict';
var DaoBase = require('./DaoBase');
var F = require('../../function');
var db = require('./models')
var util = require("util");

function CategoryDao(data) {
  data = data || {}
  data.model = data.model || db.category;
  this.data = data;
  DaoBase.call(this, this.data);
};
util.inherits(CategoryDao, DaoBase);

CategoryDao.prototype.getByAggregate = function*(pipeline, opt) {
  if (!pipeline) return F.returnData(1, '没有参数.')
  let ret = yield this.model.aggregate(pipeline).exec();
  if (ret.errors) return F.returnData(1, ret.errors, ret);
  return F.returnData(0, 'ok', ret)
};

module.exports = CategoryDao;